package com.czk.date;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/4/5 15:16
 */
public class FormatDemo {

    public static void main(String[] args) {
        DateTimeFormatter formatter1=DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
        DateTimeFormatter formatter2=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();

        // 格式化时间不一样
        // 2023-04-05 03:17:54
        System.out.println(formatter1.format(now));
        // 2023-04-05 15:17:54
        System.out.println(formatter2.format(now));

        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        System.out.println(simpleDateFormat.format(new Date()));
    }
}
